<template>
    <div class="album">
        <div class="album_list">
                <ul>
                    <li v-for="(item, index) in albumList" :key="index" @click="$router.push(`/albumlist/${item.id}`)">
                        <div class="info">
                            <img :src="item.picUrl" alt="" style="width:130px;">
                            <i :title="item.name" class="mask"></i>
                            <div class="show">
                                <i title="播放" class="play"></i>
                            </div>
                        </div>
                        <p :title="item.name" class="dec ellipsis">{{ item.name }}</p>
                        <span class="name">{{ item.publishTime | showDate }}</span>
                    </li>
                </ul>
            </div>
    </div>
</template>

<script>
import { ArtistAlbumApi } from "@/request/api";
import { formatDate } from '@/assets/utils/date'
export default {
    data () {
        return {
            albumList: [],
        }
    },
    computed: {
        id() {
          return this.$route.params.id;
        },
    },
    filters: {
      showDate: function(value) {
        let date = new Date(value);
        // return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
        return formatDate(date, 'yyyy-MM-dd');
      }
    },
    created() {
        ArtistAlbumApi(this.id).then((res) => {
            // console.log(res);
            this.albumList = res.data.hotAlbums;
        })
    }
    
}
</script>
 
<style lang = "less" scoped>
@import "../../assets/base.less";
.album {
    float: left;
    .album_list {
        margin-top: 20px;
        ul {
            flex-wrap: wrap;
            display: flex;
            justify-content: flex-start !important;
        }
        li {
            width: 160px;
            height: 180px;
            margin: 0 0 30px 0;
            line-height: 1.5;
            &:nth-of-type(4n) {
                margin-right: 0;
            }
            .info {
                cursor: pointer;
                position: relative;
                height: 130px;
                width: 160px;
                overflow: hidden;
                .mask {
                    position: absolute;
                    top: 0;
                    left: 0;
                    height: 130px;
                    width: 160px;
                    display: block;
                    background: url("../../assets/images/public/coverall.png") no-repeat 0px -845px;
                }
                &:hover {
                    .show {
                        display: block;
                    }
                    img {
                        transform: scale(1.1);
                    }
                }
                .show {
                    display: none;
                    i {
                        position: absolute;
                        bottom: 5px;
                        right: 40px;
                        height: 30px;
                        width: 30px;
                        display: block;;
                        float: right;
                        background: url("../../assets/images/public/iconall.png") no-repeat;
                    }
                    .play {
                        background-position: 0px -140px;
                        &:hover {
                            background-position: 0px -170px;
                        }
                    }
                }
            }
            .dec {
                cursor: pointer;
                width: 100%;
                font-size: 14px;
                color: #000;
                &:hover {
                    text-decoration: underline;
                }
            }
            .name {
                cursor: pointer;
                font-size: 12px;
                color: #666;
            }
        }
    }
}
</style>